﻿#region Using directives

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

#endregion

namespace Weazel.Toad.Application.Forms
{
  partial class ExceptionForm : Form
  {
    private Exception exception;

    public static void Show(Exception e)
    {
      ExceptionForm form = new ExceptionForm();
      form.exception = e;
      form.exceptionTextBox.Text = e.GetType().ToString();
      form.messageTextBox.Text = e.Message;
      form.stackTraceTextBox.Text = e.StackTrace;

      if (e.InnerException != null)
      {        
        form.nextButton.Enabled = true;       
      }
      else
      {
        form.nextButton.Enabled = false;
      }

      form.ShowDialog();
    }

    public ExceptionForm()
    {
      InitializeComponent();
    }

    private void nextButton_Click(object sender, EventArgs e)
    {
      ExceptionForm.Show(exception.InnerException);
    }
  }
}